Calculation of connectivity matrix page 161

This notebook reproduces the calculation of page 161


In [1]:
from __future__ import print_function
import sys
sys.path.append('../')

import numpy as np

from hopfield import Hopfield

n_dim = 5
n_store = 2
p_1 = np.array((1, -1, 1, 1, -1))
p_2 = np.array((1, 1, 1, -1, -1))

list_of_patterns = [p_1, p_2]

nn = Hopfield(n_dim=n_dim)
nn.train(list_of_patterns, normalize=False)

print(nn.w)


[[ 0.  0.  2.  0. -2.]
 [ 0.  0.  0. -2.  0.]
 [ 2.  0.  0.  0. -2.]
 [ 0. -2.  0.  0.  0.]
 [-2.  0. -2.  0.  0.]]

In [ ]: